package com.kob.backend.controller.user.account;

import com.kob.backend.service.user.account.InfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author QiaoQi
 * @version 1.0
 */
@RestController
public class InfoController {
    @Autowired
    private InfoService infoService;

    @GetMapping("/user/account/info/")
    public Map<String, String> getinfo() {
        return infoService.getinfo();
    }

    @PostMapping("/user/account/uploadAvatar/")
    public Map<String, String> getAvatarBase64(@RequestParam Map<String, String> map) {
        String avatarData = map.get("avatarData");
        String userId = map.get("userId");
        return infoService.uploadAvatar(avatarData, userId);
    }
    @PostMapping("/user/account/updateUsername/")
    public Map<String, String> register(@RequestParam Map<String, String> map) {
        String userId = map.get("userId");
        String newUsername = map.get("newUsername");
        return infoService.updateUsername(newUsername, userId);
    }

}
